/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.validation.BindException;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.sesame.domain.Album;
import com.sesame.domain.Collect;
import com.sesame.domain.Image;
import com.sesame.domain.User;
import com.sesame.service.AlbumService;
import com.sesame.service.ContactService;
import com.sesame.service.UserService;

/**
 * @author voidman
 * 
 */
public class ShowCollectController extends AbstractController {

    private UserService userService;

    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        Integer userId = null;
        Map model = new HashMap();
        if (request.getParameter("userId") != null) {
            userId = Integer.parseInt(request.getParameter("userId"));

        } else {
            userId = (Integer) request.getSession().getAttribute("userId");
        }

        List<Collect> collectList = userService.listCollect(userId);

        User user = userService.showUser(userId);
        model.put("user", user);

        model.put("collectList", collectList);

        return new ModelAndView("showCollect", model);
    }

}